home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / interface / GroupsDlgGeneral.cpp < prev    next >
C/C++ Source or Header  |  2011-11-06  |  5KB  |  186 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. // GroupsDlg.cpp: Implementierungsdatei
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "FileZilla server.h"
  24. #include "GroupsDlgGeneral.h"
  25. #include "GroupsDlg.h"
  26. #include "entersomething.h"
  27.  
  28. #if defined(_DEBUG) && !defined(MMGR)
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // Dialogfeld CGroupsDlgGeneral 
  36.  
  37. CGroupsDlgGeneral::CGroupsDlgGeneral(CGroupsDlg *pOwner)
  38.     : CSAPrefsSubDlg(CGroupsDlgGeneral::IDD)
  39.     , m_Comments(_T(""))
  40. {
  41.     ASSERT(pOwner);
  42.     m_pOwner = pOwner;
  43.     
  44.     //{{AFX_DATA_INIT(CGroupsDlgGeneral)
  45.     m_nMaxUsersBypass = FALSE;
  46.     m_MaxConnCount = _T("");
  47.     m_IpLimit = _T("");
  48.     //}}AFX_DATA_INIT
  49. }
  50.  
  51. CGroupsDlgGeneral::~CGroupsDlgGeneral()
  52. {
  53. }
  54.  
  55.  
  56. void CGroupsDlgGeneral::DoDataExchange(CDataExchange* pDX)
  57. {
  58.     CSAPrefsSubDlg::DoDataExchange(pDX);
  59.     //{{AFX_DATA_MAP(CGroupsDlgGeneral)
  60.     DDX_Control(pDX, IDC_GROUPS_MAXCONNCOUNT, m_cMaxConnCount);
  61.     DDX_Control(pDX, IDC_GROUPS_MAXUSERBYPASS, m_cMaxUsersBypass);
  62.     DDX_Control(pDX, IDC_GROUPS_IPLIMIT, m_cIpLimit);
  63.     DDX_Check(pDX, IDC_GROUPS_MAXUSERBYPASS, m_nMaxUsersBypass);
  64.     DDX_Text(pDX, IDC_GROUPS_MAXCONNCOUNT, m_MaxConnCount);
  65.     DDV_MaxChars(pDX, m_MaxConnCount, 9);
  66.     DDX_Text(pDX, IDC_GROUPS_IPLIMIT, m_IpLimit);
  67.     DDV_MaxChars(pDX, m_IpLimit, 9);
  68.     DDX_Control(pDX, IDC_GROUPS_GENERAL_ENABLE, m_cEnabled);
  69.     DDX_Check(pDX, IDC_GROUPS_GENERAL_ENABLE, m_nEnabled);
  70.     //}}AFX_DATA_MAP
  71.     DDX_Control(pDX, IDC_GROUPS_GENERAL_COMMENTS, m_cComments);
  72.     DDX_Text(pDX, IDC_GROUPS_GENERAL_COMMENTS, m_Comments);
  73.     DDV_MaxChars(pDX, m_Comments, 20000);
  74.     DDX_Control(pDX, IDC_FORCESSL, m_cForceSsl);
  75.     DDX_Check(pDX, IDC_FORCESSL, m_nForceSsl);
  76. }
  77.  
  78.  
  79. BEGIN_MESSAGE_MAP(CGroupsDlgGeneral, CSAPrefsSubDlg)
  80.     //{{AFX_MSG_MAP(CGroupsDlgGeneral)
  81.     //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // Behandlungsroutinen fⁿr Nachrichten CGroupsDlgGeneral 
  86.  
  87. BOOL CGroupsDlgGeneral::OnInitDialog() 
  88. {
  89.     CSAPrefsSubDlg::OnInitDialog();
  90.     
  91.     UpdateData(FALSE);
  92.     
  93.     SetCtrlState();
  94.  
  95.     return TRUE;  // return TRUE unless you set the focus to a control
  96.                   // EXCEPTION: OCX-Propertypages should return FALSE
  97. }
  98.  
  99. CString CGroupsDlgGeneral::Validate()
  100. {
  101.     UpdateData(TRUE);
  102.     
  103.     if (_ttoi(m_MaxConnCount)<0 || _ttoi(m_MaxConnCount)>999999999)
  104.     {
  105.         m_cMaxConnCount.SetFocus();
  106.         return _T("The maximum user count has to be between 0 and 999999999!");
  107.     }
  108.     if (_ttoi(m_MaxConnCount)<0 || _ttoi(m_MaxConnCount)>999999999)
  109.     {
  110.         m_cIpLimit.SetFocus();
  111.         return _T("The maximum user limit per IP has to be between 0 and 999999999!");
  112.     }
  113.     return _T("");
  114. }
  115.  
  116. void CGroupsDlgGeneral::SetCtrlState()
  117. {
  118.     t_group *pGroup = m_pOwner->GetCurrentGroup();
  119.     if (!pGroup)
  120.     {
  121.         m_cEnabled.EnableWindow(FALSE);
  122.         m_cMaxUsersBypass.EnableWindow(FALSE);
  123.         m_cMaxConnCount.EnableWindow(FALSE);
  124.         m_cIpLimit.EnableWindow(FALSE);
  125.         m_cComments.EnableWindow(FALSE);
  126.         m_cForceSsl.EnableWindow(FALSE);
  127.  
  128.         UpdateData(FALSE);
  129.     }
  130.     else
  131.     {
  132.         m_cEnabled.EnableWindow(TRUE);
  133.         m_cMaxUsersBypass.EnableWindow(TRUE);
  134.         m_cMaxConnCount.EnableWindow(TRUE);
  135.         m_cIpLimit.EnableWindow(TRUE);
  136.         m_cComments.EnableWindow(TRUE);
  137.         m_cForceSsl.EnableWindow(TRUE);
  138.     }
  139. }
  140.  
  141. BOOL CGroupsDlgGeneral::DisplayGroup(const t_group *pGroup)
  142. {
  143.     if (!pGroup)
  144.     {
  145.         m_nEnabled = 0;
  146.         m_nMaxUsersBypass = 0;
  147.         m_IpLimit = _T("");
  148.         m_MaxConnCount = _T("");
  149.         m_Comments = _T("");
  150.         m_nForceSsl = 0;
  151.         
  152.         UpdateData(FALSE);
  153.         
  154.         return TRUE;
  155.     }
  156.     
  157.     m_nEnabled = pGroup->nEnabled;
  158.     m_nMaxUsersBypass = pGroup->nBypassUserLimit;
  159.     CString str;
  160.     str.Format(_T("%d"), pGroup->nUserLimit);
  161.     m_MaxConnCount = str;
  162.     str.Format(_T("%d"), pGroup->nIpLimit);
  163.     m_IpLimit = str;
  164.     m_Comments = pGroup->comment;
  165.     m_nForceSsl = pGroup->forceSsl;
  166.     
  167.     UpdateData(FALSE);
  168.  
  169.     return TRUE;
  170. }
  171.  
  172. BOOL CGroupsDlgGeneral::SaveGroup(t_group *pGroup)
  173. {
  174.     if (!pGroup)
  175.         return FALSE;
  176.  
  177.     pGroup->nEnabled = m_nEnabled;        
  178.     pGroup->nBypassUserLimit = m_nMaxUsersBypass;
  179.     pGroup->nUserLimit = _ttoi(m_MaxConnCount);
  180.     pGroup->nIpLimit = _ttoi(m_IpLimit);
  181.     pGroup->comment = m_Comments;
  182.     pGroup->forceSsl = m_nForceSsl;
  183.     
  184.     return TRUE;
  185. }
  186.